package bpce.Entry;

import coppeer.cell.Cell;
import coppeer.cell.Entry;

public class QueryEntry implements Entry{
	
	private static final long serialVersionUID = 0L;
	private String assunto;
	private boolean propagate = true;
	private Cell source;
	
	public boolean afterPropagation() {
		return false;
	}
	
	public boolean beforePropagation() { 
		if (propagate){
			propagate = false;
			return true;
		} else return false;
	}
	
	public Entry generatePropagation(Cell neighbor) {
		return this;
	}
	
	public String getAssunto(){
		return this.assunto;
	}

	public Cell getCell(){
		return this.source;
	}

	public long getPropagationLease(Cell neighbor) {
		return 10000;
	}

	public boolean matches(Entry template) {
		try{
			QueryEntry tmpl = (QueryEntry) template;
			if (tmpl.assunto != null)
				if (!tmpl.assunto.equals(assunto)) return false;
			return true;
		}catch(Exception e){
			return false;
		}
	}

	public void setAssunto(String Assunto){
		this.assunto = Assunto;
	}

	public void setCell (Cell cell){
		this.source = cell;
	}
}